<!--
 * @Author: 黄宇/Hyuishine
 * @Date: 2022-05-16 15:08:03
 * @LastEditors: 徐伟杰
 * @LastEditTime: 2022-10-21 14:06:15
 * @Description: 
 * @Email: hyuishine@gmail.com
 * @Company: 3xData
 * @youWant: 技术服务机构=>单位基本信息
-->

<template>
  <!-- 单位基本信息 -->
  <view class="collapsePane">
    <!-- 字段标题 -->
    <view class="title" @click="status = !status">
      审核明细
      <view :class="status ? 'cuIcon-unfold' : 'cuIcon-right'" />
    </view>

    <!-- 折叠中的内容 -->
    <view class="pane" :class="status ? 'unfold' : 'fold'">

      <view class="card_form scrollPane">

        <!-- 单行表单项  -->
        <view :class="formItem.type === 'textarea' ? 'formItem_doubleRow' : 'formItem'" v-for="formItem, i in formBuild"
          :key="i">
          <!-- 字段标题 -->
          <view class="label"
            :class="auditState == '1' && formItem.label == '审核结果' ? 'required' : (auditState == '0' || auditState == null) ? 'required' : ''">
            {{ formItem.label }}</view>

          <!-- 输入区域 -->
          <template>
            <picker mode="selector" v-if="formItem.type == 'selected'" class="content" :range="typeRange"
              range-key="dictLabel" @change="changeType($event)">
              <view :style="{ color: auditShowState ? '#333' : '#999' }">{{ auditShowState || '请选择审核结果' }}</view>
            </picker>
            <textarea class="contents" v-if="formItem.type === 'textarea'" v-model="auditShowMessage"
              placeholder="请输入审核意见"></textarea>
          </template>
        </view>
      </view>

    </view>
  </view>

</template>
<script>
import { baseApiUrl } from '@/config.js';
export default {
  name: 'baseInfo',
  data() {
    return {
      baseApiUrl: baseApiUrl,
      status: false, // true为开启
      formBuild: [
        { label: '审核结果', prop: 'result', type: 'selected', require: true },
        { label: '审核意见', prop: 'message', type: 'textarea', require: true },
      ],
      typeRange: [],
      auditShowState: null, // 审核结果(展示字段)
      auditState: null, // 审核结果(提交字段)
      auditShowMessage: null, // 审核意见
    }
  },
  props: {
    form: {
      type: Object,
      default: () => { }
    }
  },
  created() {
    this.getTypeRange()

    setTimeout(() => {
      console.log(this.form)
      if (this.form.state == 2) this.auditShowState = '已通过'
      else if (this.form.state == 1) {
        this.auditShowState = '不通过'
        this.auditShowMessage = this.form.opinion
      }
    }, 1000);
  },
  mounted() {
  },
  methods: {
    getTypeRange() {
      this.$getDict('auditState').then(res => {
        this.typeRange = res
      })
    },
    changeType(e) {
      this.auditShowState = this.typeRange[e.detail.value].dictLabel
      this.auditState = this.typeRange[e.detail.value].dictValue
    }
  }
}
</script>
<style lang="scss" scoped>
.required {
  &::before {
    content: "*";
    margin: 0 10rpx;
    color: #ea0707;
  }
}
</style>